﻿using Architecture.Api.Application.Commands.RoleCommand;
using Architecture.Domain.Services.Interface;
using Architecture.Domian.Entity;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.RoleHandler
{
    public class RoleUpdateCommandHandler : IRequestHandler<RoleUpdateCommand, int>
    {
        private readonly IRoleSerivce _roleService;

        public RoleUpdateCommandHandler(IRoleSerivce roleService)
        {
            _roleService = roleService;
        }

        public async Task<int> Handle(RoleUpdateCommand request, CancellationToken cancellationToken)
        {
            return await _roleService.RoleUpdate(
                new RoleInfo
                {
                    RoleId = request.RoleId,
                    RoleName = request.RoleName,
                    CreatePerson = request.CreatePerson,
                    CreateDate = request.CreateDate,
                    RevisePerson = request.RevisePerson,
                    ReviseDate = request.ReviseDate,
                    IsDelete = request.IsDelete,
                });
        }
    }
}
